﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using DAL;
using Model;

namespace BLL
{
    /// <summary>
    ///PersonService 的摘要说明
    /// </summary>
    public class PersonService
    {
        /// <summary>
        /// 根据庭室代码获取该庭室下的人员。
        /// </summary>
        public static Obj_B_RYXX[] GetPersons(string fydm,string  tsbm)
        {
            Obj_B_RYXX[] repsons = new Obj_B_RYXX[0];

            string conStr = DBConnector.GetConnectString(fydm);
            string selectStr = string.Format("select * from {0} where xcbm={1}", Obj_B_RYXX.TableName, tsbm);
            DataTable dt = DBConnector.GetSqlSelectData(selectStr, conStr);
            if (dt != null && dt.Rows.Count > 0)
            {
                int count = dt.Rows.Count;
                repsons = new Obj_B_RYXX[count];
                for (int i = 0; i < count; i++)
                {
                    repsons[i] = new Obj_B_RYXX(dt.Rows[i]);
                }
            }
            return repsons;
        }

        /// <summary>
        /// 根据庭室代码和人员代码获取该庭室下的人员对象。
        /// </summary>
        public static Obj_B_RYXX GetPerson(string fydm, string tsbm,string rydm)
        {
            Obj_B_RYXX repson = null;

            string conStr = DBConnector.GetConnectString(fydm);
            string selectStr = string.Format("select * from {0} where xcbm={1} and dm={2}", Obj_B_RYXX.TableName, tsbm, rydm);
            DataTable dt = DBConnector.GetSqlSelectData(selectStr, conStr);
            if (dt != null && dt.Rows.Count > 0)
            {
                    repson= new Obj_B_RYXX(dt.Rows[0]);
              
            }
            return repson;
        }
    }
}
